# Contributor: Hugo Osvaldo Barrera <hugo@whynothugo.nl>
# Maintainer: Hugo Osvaldo Barrera <hugo@whynothugo.nl>
pkgname=ublock-origin
pkgver=1.57.2
pkgrel=0
pkgdesc="Efficient blocker add-on for Firefox"
url="https://github.com/gorhill/uBlock"
arch="noarch"
license="GPL-3.0-or-later"
makedepends="git python3 zip bash strip-nondeterminism"
# Upstream's build script pulls latest master for uAssets.
# Pin the versions we use so we don't need network at built-time and the package
# sources are deterministic.
_uassets_master=2d9a31529c6247843afd0f51febd479d5c5fbc60
_uassets_ghpages=e7eda5280c4978263903303916b6dba453749026
source="ublock-origin-$pkgver.tar.gz::https://github.com/gorhill/uBlock/archive/refs/tags/$pkgver.tar.gz
	uAssets-$_uassets_master.tar.gz::https://github.com/uBlockOrigin/uAssets/archive/$_uassets_master.tar.gz
	uAssets-$_uassets_ghpages.tar.gz::https://github.com/uBlockOrigin/uAssets/archive/$_uassets_ghpages.tar.gz
"
builddir="$srcdir/uBlock-$pkgver"
options="!check" # no tests

prepare() {
	default_prepare

	mkdir -p dist/build/uAssets
	mv ../uAssets-$_uassets_master dist/build/uAssets/main
	mv ../uAssets-$_uassets_ghpages dist/build/uAssets/prod
}

build() {
	make firefox
	strip-nondeterminism -t zip -T "$SOURCE_DATE_EPOCH" dist/build/uBlock0.firefox.xpi
}

package() {
	install -Dm644 dist/build/uBlock0.firefox.xpi "$pkgdir/usr/lib/firefox/browser/extensions/uBlock0@raymondhill.net.xpi"
}

sha512sums="
417de98dec542d4a21fa114ab29dfb3d4251b5e6302997bbefa08cce4440aba7fcda5866f9d30c6f18e466087fe38e98df695a9aee3320c279e7f53a6b2d93fb  ublock-origin-1.57.2.tar.gz
0934ada631ca4a88f35313b74e4f54a29c16ed22560bc020b9e1debe50d04bd38bd37c566efd9cc9e9a7d9a1797b31ae6d56fd3fbafc1223f29eeefeeb73cc7b  uAssets-2d9a31529c6247843afd0f51febd479d5c5fbc60.tar.gz
4bf8492795a70836ef017b8305dff4d335700bc54849ac09c8279b7294f4a56f51e7450fb32f818c31bd9b7a182240eb3b95283590b3994aa364c15550470f8f  uAssets-e7eda5280c4978263903303916b6dba453749026.tar.gz
"
